<template>
	<div class="groupDetail" v-if='groupDetails' :class='{groupDetaildown:download}'>
	    <download @close-down='closeDowns' v-if='download'></download>
		<x-header title="拼团详情" :left-options="{backText:''}" class='whiteHeader' @click='goBack'></x-header>
		<div class="allMess">
			<div class="shopMess" @click='goShopDetail(groupDetails.SERV_ID)'>
				<img :src="groupDetails.SERVDETAIL_PHOTO" alt="" />
				<div class="shopDetailMess">
					<h1>{{groupDetails.SERV_SUBJECT}}</h1>
					<p><img src="../../assets/image/group/personDetail.png" alt="" /><span>{{groupDetails.GROUPONGOODS_NUM}}人已拼</span></p>
					<div class="groupPrice">
						<h2><label>￥</label>{{groupDetails.GROUPONGOODS_PRICE}}</h2>
						<div class="priceO">
							<h3>{{groupDetails.START_NUM}}人成团价</h3>
							<s>单买价￥{{groupDetails.PRICE}}</s>
						</div>
					</div>
				</div>
			</div>
			<div class="grouType">
				<div class="type" v-if='groupType==1'>
					<h1>恭喜，拼团成功！</h1>
					<h2>请耐心等待收货吧！</h2>
				</div>
				<div class="type" v-if='groupType==2||groupType==5'>
					<h1>已开团，离成团还差{{groupDetails.DIFFER}}人</h1>
					<p>剩<span> {{downObj.H}}:</span><span>{{downObj.M}}:</span><span>{{downObj.S}} </span>自动结束</p>
					<h2>好货手慢无，快来买哟！<a href="http://carnt.carnettong.com:8088/CARNT/GroupPlayDetail/GroupPlayDetail.html">玩法详情></a></h2>
				</div>
				<div class="type" v-if='groupType==3||groupType==6'>
					<h1>哎呀，人没凑齐，团失败</h1>
					<h2>别急，赶紧开个新团，自己当团长<a href="http://carnt.carnettong.com:8088/CARNT/GroupPlayDetail/GroupPlayDetail.html">玩法详情></a></h2>
				</div>
				<div class="type" v-if='groupType==4'>
					<h1>哎呀，你来晚了，该团已满</h1>
					<h2>别急，赶紧开个新团，自己当团长哟！<a href="http://carnt.carnettong.com:8088/CARNT/GroupPlayDetail/GroupPlayDetail.html">玩法详情></a></h2>
				</div>
				<div class="type" v-if='groupType==7'>
					<h1>恭喜，拼团成功</h1>
					<h2>等待抽奖 ~</h2>
				</div>
				<div class="type" v-if='groupType==8'>
					<h1>恭喜，拼团成功</h1>
					<h2>快去查看开奖详情吧 ></h2>
				</div>
			</div>
			<div class="groupUser">
				<div class="userImg" v-for='item in groupUser' :class='{activeGroup:item.IS_LEADER==1}'>
					<img :src="item.SPICT_USERS_PATH" alt="" />
					<span v-if='item.IS_LEADER==1'>团长</span>
				</div>
				<div class="userImg" v-if='groupType==2||groupType==5'  v-for='i in num'>
					<img src="../../assets/image/group/noPerson.png" alt="" />
				</div>
				<div class="userImg" v-if='groupType==3||groupType==6'  v-for='i in num'>
					<img src="../../assets/image/group/fail.png" alt=""  />
				</div>
			</div>
			<div class="invitation" v-if='groupType==8' @click='goWiningDetail(groupDetails.ORDER_ID)'>
				开奖详情
			</div>
			<div class="invitation" v-if='groupType==2' @click='showShareClick'>
				邀请好友凑单
			</div>
		</div>
		<div class="userLike">
			<div class="userLikeHead">
				<!-- <div class="line"></div>
				<span>猜你喜欢</span> -->
				<img src="../../assets/image/group/userLike.png" alt="" />
			</div>
			<div class="allProduct">
	          <div class="listItem productBorder" v-for='item in groupDetails.GUESS_LIKE' @click='goShopDetail(item.SERVDETAIL_ID)'>
	            <img :src="item.SERVDETAIL_PHOTO" alt="" />
	            <p>{{item.REMARK}}</p>
	            <h2>{{item.SERVDETAIL_NAME}}</h2>
	            <div class="price">
	              <span>拼团价:<label>￥</label>{{item.GROUPONGOODS_PRICE}}</span>
	              <s>￥{{item.SERVDETAIL_PRICE}}</s>
	            </div>
	          </div>
	        </div>
		</div>
		<popup v-model="showPop">
	      <div class="popRule">
	        <div class="popHead">
	          <div class="popHLeft" v-if='groupDetails.SERVDETAIL_PHOTO'>
	            <img :src="groupDetails.SERVDETAIL_PHOTO" alt=""/>
	          </div>
	          <div class="popHCenter">
	            <h1>￥{{Number(watchSelect.prices)}}</h1>
	            <p v-if='watchSelect.str!=""'>已选择：{{watchSelect.str}}</p>
	            <p v-if='watchSelect.str==""'>请选择商品的属性</p>
	          </div>
	          <div class="popHRight">
	            <img src="../../assets/image/carProduct/close.png" @click='closePop'/>
	          </div>
	        </div>
	        <div class="popMain">
	          <div class="rule" v-for='(items,index) in groupDetails.ATTR_LIST'>
	            <p>{{items.TYPE}}</p>
	            <div class="ruleDetail">
	              <span v-for='(itemss,indexs) in items.ATTRIBURE' :class='{activeSpan:itemss.IS_SELECT==1}' @click='selectClass(index,indexs)'>{{itemss.SERV_NAME}}</span>
	            </div>
	          </div>
	          <!-- <div class="number">
	            <group>
	              <x-number title="数量" :step="1" :min='1' v-model='number'></x-number>
	            </group>
	          </div> -->
	        </div>
	        <div class="popFooter" @click='determine'>
	          {{popText}}
	        </div>
	      </div>
	    </popup>
		<div class="footerBars">
			<div class="addGroup type1" v-if='groupType==5' @click='addGroup'>我要参团</div>
			<div class="orderDetail type1" v-if='groupType==2||groupType==1||groupType==7||groupType==8' @click='goOrderDetail'>查看订单详情</div>
			<div class="openGroup type1" v-if='(groupType==4||groupType==3||groupType==6)&&openGroupCan' @click='openGroup'>我来开新团</div>
			<div class="moreGroup" @click='goAllGroup'>更多团购商品</div>
		</div>
		<shareToast :share='showShare' @close-share='closeShare'></shareToast>
	</div>
</template>
<script>
	/*智能保养*/
import { XHeader,Group,Popup } from 'vux';
import { setCookie, getCookie,clearCookie,isWeiXin,wXAuthJump,sendWXCodeOrOpenid,GetQueryString,appid,reloads,iosAdroidWx,pushStateUrl} from '../../util/commonUtils';
import shareToast from '../../components/shareToast.vue'; //分享弹框
import download from '../../components/download';
import wx from 'weixin-js-sdk'//微信jssdk
export default {
	name: "groupDetail",
	// 数据
	data() {

		return {
			userId: '',
			groupId:'',  //团购id
			groupDetails:'',
			downObj:{
	        	H:0,
	        	M:0,
	        	S:0
	        },
	        showShare:false,
	        showPop:false,
	        popText:'我要参团',
	        groupClass:0,   //0 我要参团  1我要开团
	        closeTime:'',
	        closeTime1:'',
	        groupUser:'',
	        clickKey:false,  //点击开关
	        openGroupCan:true,  //判断是否可以开新团
	        download:true
		}
	},
	// 计算属性
	computed: {
		groupType(){
			if(this.groupDetails.USER_STATUS==1&&this.groupDetails.GROUPON_STATUS==1){//拼团成功
				if(this.groupDetails.GROUPON_TYPE==2&&this.groupDetails.PRIZE_STATUS==1){
					//一分拼团，已开奖
					return 8;
			    }else if(this.groupDetails.GROUPON_TYPE==2&&this.groupDetails.PRIZE_STATUS==0){
					//一分拼团，带开奖
					return 7;
				}
				return 1;
			}else if(this.groupDetails.USER_STATUS==1&&this.groupDetails.GROUPON_STATUS==2){//拼团进行中
				return 2;
			}else if(this.groupDetails.USER_STATUS==1&&this.groupDetails.GROUPON_STATUS==0){//拼团失败
				return 3;
			}else if(this.groupDetails.USER_STATUS==0&&this.groupDetails.GROUPON_STATUS==1){//用户未在该拼团中,且该团成功状态
				return 4;
			}else if(this.groupDetails.USER_STATUS==0&&this.groupDetails.GROUPON_STATUS==2){//用户未在该拼团中，且该处于进行中状态
				return 5;
			}else if(this.groupDetails.USER_STATUS==0&&this.groupDetails.GROUPON_STATUS==0){//用户未在该拼团中，且该处于失败状态
				return 6;
			}
		},
		num(){
			if(this.groupDetails){
				if((this.groupDetails.START_NUM-this.groupDetails.SPICT_USERS_PATH_LIST.length)<0){
					return 0;
				}else{
					return this.groupDetails.START_NUM-this.groupDetails.SPICT_USERS_PATH_LIST.length;
				}
				
			}
			
		},
		watchSelect(){
	      let arr=this.groupDetails.ATTR_LIST;
	      let str='';
	      let sum=0;
          let prices=0;
	      let obj={};//加入购物车的数据
	      if(this.groupDetails.ATTR_LIST){
	        obj.PARAMS=[];
	        let objs={};
	        objs.SHOP_NAME=this.groupDetails.SHOP_NAME;
	        objs.SERV_ID=this.groupDetails.SERV_ID;
	        objs.QUANTITY=1; 
	        objs.COMP_ID=this.groupDetails.COMP_ID;
	        objs.ATTR_LIST=[];
	        for(let i=0;i<this.groupDetails.ATTR_LIST.length;i++){
	          for(let j=0;j<this.groupDetails.ATTR_LIST[i].ATTRIBURE.length;j++){
	            let objss={};
	            if(this.groupDetails.ATTR_LIST[i].ATTRIBURE[j].IS_SELECT==1){
	              objss.ATTRIBURE=this.groupDetails.ATTR_LIST[i].ATTRIBURE[j].SERV_ID;
	              objss.TYPE=this.groupDetails.ATTR_LIST[i].TYPE;
	              objs.ATTR_LIST.push(objss);
	              str+='['+this.groupDetails.ATTR_LIST[i].TYPE+']';
	              str+=this.groupDetails.ATTR_LIST[i].ATTRIBURE[j].SERV_NAME+' ';
	              sum+=Number(this.groupDetails.ATTR_LIST[i].ATTRIBURE[j].PRICE);
	            }
	          }
	        }
            objs.price=Number(this.groupDetails.GROUPONGOODS_PRICE)+sum;
            prices=Number(this.groupDetails.GROUPONGOODS_PRICE)+sum;
	        obj.PARAMS.push(objs);
	      }
	      return {
	        str:str,
	        sum:sum,
            prices:prices,
	        addObj:obj
	      }
	    },
      //判断是否选择了所有的规格和属性
      allSelect(){
        let arr=this.groupDetails.ATTR_LIST;
        let flag=false;
        if(this.groupDetails.ATTR_LIST){
          if(this.groupDetails.ATTR_LIST.length==0){
            return true;
          }
          for(let i=0;i<this.groupDetails.ATTR_LIST.length;i++){
            for(let j=0;j<this.groupDetails.ATTR_LIST[i].ATTRIBURE.length;j++){
              if(this.groupDetails.ATTR_LIST[i].ATTRIBURE[j].IS_SELECT==1){
                flag=true;
              }
            }
            if(!flag){
              break;
            }
          }
          if(!flag){
            return false;
          }else{
            return true;
          }
        }
      }
	},
	// 创建（实例创建完成）
	created() {
		 if(sessionStorage.getItem('reload')){
		    sessionStorage.removeItem('reload');
		 }else{
	        sessionStorage.setItem('reload',1);
	        pushStateUrl();
	        reloads();
	        return;
		}
		this.userId = getCookie('loginkey');
		this.groupId=this.$route.params.id;
		this.getGroupDetail();
		// 1代表开新团，2代表参团
		if(sessionStorage.getItem('openGroups')==1&&!this.clickKey){
	      this.clickKey=true;
	      this.openGroup();
	    }else if(sessionStorage.getItem('openGroups')==2&&!this.clickKey){
	      this.clickKey=true;
	      this.addGroup();
	    }
	},
	// el被创建，并挂载到实例上
	mounted() {

	},
	// 方法（实例中的方法）-----------
	methods: {
		goBack(){
			this.$router.go(-1);
		},
		closeDowns(val){
	      this.download=false;
	      sessionStorage.setItem('closeDown',1);
	    },
		showShareClick(){
	      this.showShare=true;
	    },
	    //开奖详情
	    goWiningDetail(id){
	    	this.$router.push('/winingDetail/'+id);
	    },
	    closeShare(){
	      this.showShare=false;
	    },
	    goShopDetail(id){
	    	location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopDetail/'+id;
	    	// if(this.groupDetails.GROUPON_TYPE==1){
	    	// 	location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopDetail/'+id;
	    	// }else if(this.groupDetails.GROUPON_TYPE==2){
	    	// 	location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopDetail/'+id+'?groupId=2';
	    	// }else if(this.groupDetails.GROUPON_TYPE==3){
	    	// 	location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopDetail/'+id+'?groupId=3';
	    	// }
	    	
	    },
	    commonShare(){
	        let imgUrl=this.groupDetails.SERVDETAIL_PHOTO;
			let title=`一起开团，享受超值${this.groupDetails.GROUPONGOODS_PRICE}元拼${this.groupDetails.SERV_SUBJECT}`;
			this.getConfig(imgUrl,title);
	    },
		getGroupDetail(){
			this.$fetchPost('/Groupon/getGrouponGoodsDetail.action',{
	          GROUPON_USER_ID:this.groupId,
	          USER_ID:this.userId
	        }).then(res=>{
	          if(res.STATUS_CODE==1){
	          	this.groupDetails=res;
	          	let groupUser=res.SPICT_USERS_PATH_LIST;
	          	let index='';
	          	let newArr=[];
	          	for(let j=0;j<groupUser.length;j++){
	          		if(groupUser[j].IS_LEADER==1){
	          			newArr.unshift(groupUser[j]);
	          		}else{
	          			newArr.push(groupUser[j]);
	          		}
	          	}
	          	this.groupUser=newArr;
	          	for(let i=0;i<this.groupDetails.ATTR_LIST.length;i++){
	              for(let j=0;j<this.groupDetails.ATTR_LIST[i].ATTRIBURE.length;j++){
	                this.$set(this.groupDetails.ATTR_LIST[i].ATTRIBURE[j],'IS_SELECT',0);
	              }
	            }
	            if(this.groupDetails.GROUPON_STATUS==2){
	            	this.closeTime=setInterval(()=>{
		          		this.checkGroup();
		          	},500)
	            }
	            if(this.groupDetails.GROUPON_STATUS==0||this.groupDetails.GROUPON_STATUS==1){
	            	this.closeTime1=setInterval(()=>{
		          		this.checkGroup1();//控制我要开新团的按钮
		          	},500)
	            }
	            if(this.groupDetails.USER_STATUS==1&&this.groupDetails.GROUPON_STATUS==2){
	            	let imgUrl=this.groupDetails.SERVDETAIL_PHOTO;
					let title=`【还剩${this.groupDetails.DIFFER}个名额】，一起${this.groupDetails.GROUPONGOODS_PRICE}元拼${this.groupDetails.SERV_SUBJECT}`;
					this.getConfig(imgUrl,title);
	            }else{
	            	this.commonShare();
	            }
	          }
	        },err=>{
	          console.log(err);
	        })
		},
		checkGroup(){
	        var times=new Date().getTime();
	        let H=0;
	        let M=0;
	        let S=0;
	        if(times>=this.groupDetails.CLOSE_TIME){
	        	clearInterval(this.closeTime);
	        	this.$set(this.groupDetails,'GROUPON_STATUS',0);
	        }else{
	          H=parseInt((this.groupDetails.CLOSE_TIME-times)/(60*60*1000));
	          M=parseInt((this.groupDetails.CLOSE_TIME-times-H*60*60*1000)/(60*1000));
	          S=parseInt((this.groupDetails.CLOSE_TIME-times-H*60*60*1000-M*60*1000)/(1000));
	          H=this.filterNum(H);
	          M=this.filterNum(M);
	          S=this.filterNum(S);
	        }
	        this.downObj={
	        	H:H,
	        	M:M,
	        	S:S
	        }
	    },
	    checkGroup1(){
	    	var times=new Date().getTime();
	    	if(times>=this.groupDetails.GROUPON_CLOSE_TIME){
	    		this.openGroupCan=false;
	    		clearInterval(this.closeTime1);
	    	}
	    },
	    filterNum(num){
	      return num>=10?num:'0'+num
	    },
	    //我要参团
	    addGroup(){
	    	let code = GetQueryString('code');
			let unionid=getCookie('_unionidpo_');
			if(isWeiXin()){
			  let that=this;
			  // 1.是微信环境下
			  // 不存在openid 检查是否有code参数
			  if ( code || unionid) {
			    sendWXCodeOrOpenid.call(that).then(function (data) {
			      // 储存code拉回的openid
			      if ( data.STATUS_CODE == 1) {
			        //获取用户微信信息
			        sessionStorage.removeItem('openGroups');
			        setCookie('_unionidpo_', data.AUTH_INFO.unionid);//用户的unionid
			        setCookie("headerImg",data.AUTH_INFO.headimgurl);
			        setCookie("userN",data.AUTH_INFO.nickname);
			        if(data.IS_BINDING==0){
			          that.$router.push('/modifyGroup');
			        }else if(data.USER_ID){
			          setCookie("userName",data.MOBILE);
			          setCookie("loginkey",data.USER_ID);
			          setCookie('CAR_ID',data.CAR_ID);
			          setCookie('INV_CODE',data.INV_CODE);
			          setCookie('INV_URL',data.INV_URL);
			          that.userId=data.USER_ID;
			          that.addGroups();
			        }
			      }else if(data.STATUS_CODE == 2){
			      	sessionStorage.setItem('openGroups',2);
			      	clearCookie('_unionidpo_');
			      	let urls=window.getIps+'/CARNT/jsp/pay/indexM.html?#/groupDetail/'+that.groupId;
			        wXAuthJump.call(that,urls);
			      }
			    })
			  }
			  // 不存在code也无openid
			  else {
			  	sessionStorage.setItem('openGroups',2);
			    // 跳转微信授权地址 （之后再跳回页面，流程重头来过）
			    let urls=window.getIps+'/CARNT/jsp/pay/indexM.html?#/groupDetail/'+this.groupId;
			    wXAuthJump.call(that,urls);
			    return;
			  }
			}else{
			  this.addGroups();
			}
	    },
	    addGroups(){
	    	this.groupClass=0;
	    	this.popText='我要参团';
	    	let flag=this.checkAdd();
	        if(!flag){
	          this.showPop=true;
	          return;
	        }//封装支付数据
	        let settleMess=this.encapsulateData();
		    settleMess.ORDER_LIST[0].GROUPON_TYPE='17092852';
		    settleMess.ORDER_LIST[0].GROUPON_TYPES=this.groupDetails.GROUPON_TYPE;
		    settleMess.ORDER_LIST[0].PID=this.groupDetails.GROUPON_USER_ID;
		    sessionStorage.removeItem('orderMess');
		    sessionStorage.removeItem('distribuVoucher');
		    localStorage.removeItem('from');
		    sessionStorage.setItem('cGroup',1);//代表参团
		    sessionStorage.setItem('shopMess',JSON.stringify(settleMess));//商品支付的数据
		    //this.$router.push('/shopPay');
		    location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopPay';
	    },
	    openGroups(){
	    	this.groupClass=1;
	    	this.popText='我要开团';
	    	let flag=this.checkAdd();
	        if(!flag){
	          this.showPop=true;
	          return;
	        }//封装支付数据
	        let settleMess=this.encapsulateData();
		    settleMess.ORDER_LIST[0].GROUPON_TYPE='17092852';
		    settleMess.ORDER_LIST[0].GROUPON_TYPES=this.groupDetails.GROUPON_TYPE;
		    settleMess.ORDER_LIST[0].PID=0;
		    sessionStorage.removeItem('orderMess');
	        sessionStorage.removeItem('distribuVoucher');
	        localStorage.removeItem('from');
	        sessionStorage.setItem('shopMess',JSON.stringify(settleMess));//商品支付的数据
	        //this.$router.push('/shopPay');
	        location.href=window.getIps+'/CARNT/jsp/pay/indexM.html#/shopPay';
	    },
	    //我要开新团
	    openGroup(){
	    	let code = GetQueryString('code');
			let unionid=getCookie('_unionidpo_');
			if(isWeiXin()){
			  let that=this;
			  // 1.是微信环境下
			  // 不存在openid 检查是否有code参数
			  if ( code || unionid) {
			    sendWXCodeOrOpenid.call(that).then(function (data) {
			      // 储存code拉回的openid
			      console.log(data)
			      if ( data.STATUS_CODE == 1) {
			        //获取用户微信信息
			        sessionStorage.removeItem('openGroups');
			        setCookie('_unionidpo_', data.AUTH_INFO.unionid);//用户的unionid
			        setCookie("headerImg",data.AUTH_INFO.headimgurl);
			        setCookie("userN",data.AUTH_INFO.nickname);
			        if(data.IS_BINDING==0){
			          that.$router.push('/modifyGroup');
			        }else if(data.USER_ID){
			          setCookie("userName",data.MOBILE);
			          setCookie("loginkey",data.USER_ID);
			          setCookie('CAR_ID',data.CAR_ID);
			          setCookie('INV_CODE',data.INV_CODE);
			          setCookie('INV_URL',data.INV_URL);
			          that.userId=data.USER_ID;
			          that.openGroups();
			        }
			      }else if(data.STATUS_CODE == 2){
			      	sessionStorage.setItem('openGroups',1);
			      	clearCookie('_unionidpo_');
			        let urls=window.getIps+'/CARNT/jsp/pay/indexM.html?#/groupDetail/'+this.groupId;
			        wXAuthJump.call(that,urls);
			      }
			    })
			  }
			  // 不存在code也无openid
			  else {
			  	sessionStorage.setItem('openGroups',1);
			    // 跳转微信授权地址 （之后再跳回页面，流程重头来过）
			    let urls=window.getIps+'/CARNT/jsp/pay/indexM.html?#/groupDetail/'+this.groupId;
			    wXAuthJump.call(that,urls);
			    return;
			  }
			}else{
			  this.openGroups();
			}
	    },
	    //弹框里的确定按钮
	    determine(){
		    // let flag=this.checkAdd();
		    //    if(!flag){
		    //      this.showPop=true;
		    //      return;
		    //    }//封装支付数据
	    	this.showPop=false;
	    	if(this.groupClass==0){
	    		this.addGroups();
	    	}else{
	    		this.openGroups();
	    	}
	    },
	    closePop(){
	    	this.showPop=false;
	    },
	    selectClass(index,indexs){
	        for(let j=0;j<this.groupDetails.ATTR_LIST[index].ATTRIBURE.length;j++){
	          this.$set(this.groupDetails.ATTR_LIST[index].ATTRIBURE[j],'IS_SELECT',0);
	        }
	        this.$set(this.groupDetails.ATTR_LIST[index].ATTRIBURE[indexs],'IS_SELECT',1);
	    },
	    //去所有团购商品
	    goAllGroup(){
	    	if(this.groupDetails.GROUPON_TYPE==1){
	    		this.$router.push('/groupList');
	    	}else if(this.groupDetails.GROUPON_TYPE==2){
	    		this.$router.push('/oneGroup');
	    	}else if(this.groupDetails.GROUPON_TYPE==3){
	    		this.$router.push('/freeGroup');
	    	}
	    	
	    },
	    //查看订单详情
	    goOrderDetail(){
	    	this.$router.push('/gOrderDetail/'+this.groupDetails.ORDER_ID);
	    },
	    encapsulateData(){
	      let settleMess={};
	      settleMess.USER_ID=this.userId;
	      settleMess.ZERO_STATUS=this.groupDetails.ZERO_STATUS;
	      settleMess.ORDER_LIST=[];
	      let objs={};
	      objs.COMP_ID=this.watchSelect.addObj.PARAMS[0].COMP_ID;
	      objs.SHOP_NAME=this.watchSelect.addObj.PARAMS[0].SHOP_NAME;
	      objs.SERV_PARAMS=[];
	      let objss={};
	      objss.SERV_ID=this.watchSelect.addObj.PARAMS[0].SERV_ID;
	      objss.QUANTITY=this.watchSelect.addObj.PARAMS[0].QUANTITY;
	      objss.SERV_FIRST_CLASS=this.groupDetails.SERV_FIRST_CLASS;
	      objss.SERV_SECON_CLASS=this.groupDetails.SERV_SECON_CLASS;
	      objss.SUPP_CASH_VOL=this.groupDetails.SUPP_CASH_VOL;
	      objss.SUPP_DIS_VOL=this.groupDetails.SUPP_DIS_VOL;
	      objss.SUPP_NOR_CASH_VOL=this.groupDetails.SUPP_NOR_CASH_VOL;
	      objss.SERV_SUBJECT=this.groupDetails.SERV_SUBJECT;//商品名称
	      objss.PRICE=Number(this.groupDetails.GROUPONGOODS_PRICE)+Number(this.watchSelect.sum);//商品价格
	      objss.MARK=1;
	      objss.ATTR_LIST=[];
	      for(let i=0;i<this.watchSelect.addObj.PARAMS[0].ATTR_LIST.length;i++){
	        let objAtr={};
	        objAtr.ATTRIBURE=String(this.watchSelect.addObj.PARAMS[0].ATTR_LIST[i].ATTRIBURE);
	        objAtr.TYPE=this.watchSelect.addObj.PARAMS[0].ATTR_LIST[i].TYPE;
	        objss.ATTR_LIST.push(objAtr);
	      }
	      objs.SERV_PARAMS.push(objss);
	      settleMess.ORDER_LIST.push(objs);
	      return settleMess;
	    },
	    checkAdd(){
	      let that=this;
	      if(!getCookie('loginkey')){//判断是否登录
	        this.$vux.confirm.show({
	          title:'提示',
	          content:'请先登录',
	          onConfirm () {
	            that.$router.push('/login');
	          }
	        })
	        return false;
	      }
	      if(this.groupDetails.ATTR_LIST.length==0){//无属性列表
	        return true;
	      }
	      if(this.allSelect){//判断是否选择了所有的属性和规格
	        this.showPop=false;
	        return true;
	      }else{
	        this.showPop=true;
	        return false;
	      }
        },
        //获取微信的配置信息
	    getConfig(imgUrl,title){
	      let timestamp,nonceStr,signature;
	      let desc='全民火拼，拼团专享优惠，超值一拼到底';
	      let urls=iosAdroidWx().urls;
          let appid=iosAdroidWx().appid;
	      this.$fetchPost(urls,{'url' : window.location.href},{emulateJSON:true})
	      .then(res=>{
	        var data = res;
	        // timestamp = data.timestamp;
	        // nonceStr =  data.nonceStr;
	        // signature = data.signature;
	        timestamp=data.NOW_TIME;
	        nonceStr=data.NONCESTR;
	        signature=data.SKEY;
	        // console.log(timestamp,nonceStr,signature,appId)
	        wx.config({
	            debug : false, // 开启调试模式,false调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
	            appId :appid, // 必填，公众号的唯一标识
	            timestamp : timestamp, // 必填，生成签名的时间戳
	            nonceStr : nonceStr, // 必填，生成签名的随机串
	            signature : signature,// 必填，签名，见附录1
	            jsApiList : [ 'onMenuShareTimeline', 'onMenuShareAppMessage','chooseWXPay', 'showOptionMenu' ]
	        });
	        let that=this;
	        let linkUrl=location.href;
	        wx.ready(function(){
	          // 分享给朋友
	          wx.onMenuShareAppMessage({
	            title: title,
	            desc: desc,
	            link: linkUrl,
	            imgUrl: imgUrl,
	            trigger: function (res) {
	            },
	            success: function (res) {
	            },
	            cancel: function (res) {
	            },
	            fail: function (res) {
	              alert(JSON.stringify(res));
	            }
	          }); 

	          //分享朋友圈
	          wx.onMenuShareTimeline({
	            title: title,
	            desc: desc,
	            link: linkUrl,
	            imgUrl: imgUrl,
	            trigger: function (res) {
	            },
	            success: function (res) {
	            },
	            cancel: function (res) {
	            },
	            fail: function (res) {
	              alert(JSON.stringify(res));
	            }
	          });
	        })
	      },err=>{

	      });
	    }
	},
	// 子组件
	components: {
		XHeader,shareToast,Group,Popup,download
	}
}
</script>
<!--当前页面的样式 -->
<style lang="less" scoped>
@import url('../../assets/css/public.less');
.groupDetaildown{
	padding-top: 0.88rem;
}
.groupDetail {
	background: #fff;
	min-height: 100%;
	padding-bottom: 1.2rem;
	.footerBars{
		padding:0.15rem 0;
		font-size: 0.3rem;
		position: fixed!important;
		bottom: 0;
		background: #fff;
		display: flex;
		justify-content:flex-end;
		width: 7.5rem;
		z-index: 500;
		.borderTFu(#ddd);
		.type1{
			width: 2.6rem;
			height: 0.78rem;
			color: #ec2121;
			line-height: 0.82rem;
			.borderFu(#ec2121,0.2rem);
			margin-right: 0.2rem;
		}
		.moreGroup{
			width: 2.6rem;
			height: 0.78rem;
			background: #ec2121;
			color: #fff;
			line-height: 0.82rem;
			border-radius: 0.1rem;
			margin-right: 0.2rem;
		}
	}
	.userLike{
		.userLikeHead{
			position: relative;
			height: 1rem;
			padding: 0.35rem;
			img{
				width: 2rem;
				height: 0.29rem;
				display: block;
				margin: 0 auto;
			}
			.line{
				width: 2.4rem;
				height: 0.02rem;
				position: absolute;
				background: #222;
				top: 50%;
				left: 50%;
				transform:scaleY(0.5) translate(-50%,-50%);
			}
			span{
				font-size: 0.3rem;
				color: #222;
				line-height: 1rem;
				padding: 0 0.1rem;
				background: #fff;
				line-height: 0.5rem;
				position: absolute;
				top: 50%;
				left: 50%;
				transform:translate(-50%,-50%);
			}
		}
		.allProduct{
	        display: flex;
	        justify-between:space-around;
	        flex-wrap:wrap;
	        .listItem{
	           padding: 0rem 0 0.9rem 0;
	           margin: 0 0.1rem 0.1rem 0.175rem;
	           box-sizing: border-box;
	           position: relative;
	           img{
	            width: 3.5rem;
	            height: 3rem;
	            background: #f7f7f7;
	            display: block;
	           }
	           h2{
	            width: 3.5rem;
	            margin-top: 0.2rem;
	            font-size: 0.26rem;
	            line-height: 0.35rem;
	            padding: 0 0.15rem;
	            color: #222;
	            overflow : hidden;
	            text-overflow: ellipsis;
	            display: -webkit-box;
	            -webkit-line-clamp: 2;
	            -webkit-box-orient: vertical;
	           }
	           p{
	            font-size: 0.22rem;
	            z-index: 2;
	            height: 0.5rem;
	            line-height: 0.5rem;
	            position:relative;
	            width: 3.46rem;
	            margin: 0 auto;
	            background: #f7f7f7;
	            color: #EC2121;
	           }
	           .price{
	            width: 3.5rem;
	            position: absolute;
	            bottom: 0.1rem;
	            display: flex;
	            justify-content:space-between;
	            align-items:flex-end;
	            padding: 0.15rem 0.2rem 0.05rem 0.2rem;
	             s{
	              font-size: 0.23rem;
	              color: #999;
	             }
	             span{
	              font-size: 0.28rem;
	              color:#f22e2e;
	              padding-right: 0.15rem;
	              label{
	              	font-size: 0.2rem;
	              }
	             }
	           }
	        }
	        .listItem:nth-child(2n){
	          padding: 0rem 0rem 0.1rem 0;
	          margin: 0 0.175rem 0.1rem 0;
	        }
	      }
	    /*边框一像素*/
	    .productBorder{
	      position:relative;
	    }
	    .productBorder::after {
	      content: "";
	      box-sizing: border-box;
	      position: absolute;
	      left: 0;
	      top: 0;
	      width: 200%;
	      height: 200%;
	      transform:scale(0.5,0.5);
	      transform-origin:0 0;
	      border: 1px solid #e1e2df;
	    }
	}
	.allMess{
		padding-bottom: 0.3rem;
		border-bottom:0.2rem solid #EFEFF4;
		.invitation{
			width: 2.6rem;
			height: 0.6rem;
			display: flex;
			justify-content:center;
			align-items:center;
			font-size: 0.28rem;
			color: #ec2121;
			line-height: 0.66rem;
			margin: 0.3rem auto 0;
			.borderFu(#ec2121,0.6rem);
		}
		.groupUser{
			display: flex;
		    justify-content:center;
			.userImg{
				position: relative;
				margin: 0 0.2rem;
				width: 0.9rem;
				height: 0.9rem;
				span{
					position: absolute;
					bottom: -0.05rem;
					font-size: 0.2rem;
					color: #fff;
					left: 50%;
					margin-left: -0.35rem;
					background: #F83F3F;
					width: 0.7rem;
					height: 0.28rem;
					line-height: 0.34rem;
					border-radius: 0.15rem;
					font-size: 0.2rem;
				}
			}
			.activeGroup{
				/* .borderFu(#ec2121,0.86rem); */
				border:0.02rem solid #ec2121;
				border-radius: 0.45rem;
			}
			img{
				width: 0.86rem;
				height: 0.86rem;
				border-radius: 50%;
				display: block;
			}
		}
		.grouType{
			.type{
				h1{
					font-size: 0.3rem;
					color: #222;
					margin: 0.8rem 0 0.2rem 0;
					font-weight: bold;
				}
				p{
					font-size: 0.26rem;
					color: #666;
					padding: 0.1rem 0 0.2rem 0;
					span{
						color: #333;
					}
				}
				h2{
					font-size: 0.26rem;
					color: #999;
					padding: 0.1rem 0 0.4rem 0;
					a{
						font-size: 0.24rem;
						color: #FF8C05;
					}
				}
			}
		}
		.shopMess{
			width: 7.1rem;
			height: 2.8rem;
			margin:0.32rem auto;
			border-radius: 0.2rem;
			box-shadow: 2px 2px 15px rgba(0,0,0,0.05),-2px -2px 15px rgba(0,0,0,0.05),2px -2px 15px rgba(0,0,0,0.05),-2px 2px 15px rgba(0,0,0,0.05);
			background:rgba(0,0,0,0.1) url(../../assets/image/group/groupDetail.png) no-repeat;
			background-size: 7.1rem 2.8rem;
			display: flex;
			img{
				width: 2.6rem;
				height: 2.3rem;
				margin: 0.25rem 0rem 0.25rem 0.3rem;
			}
			.shopDetailMess{
				padding: 0 0 0 0.08rem;
				text-align: left;
				h1{
					font-size: 0.32rem;
					color: #222;
					overflow : hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					margin: 0.4rem 0 0.21rem 0;
					width: 4.12rem;
				}
				p{
					display: flex;
					align-items:center;
					img{
						width: 0.31rem;
						height: 0.26rem;
						margin: 0;
					}
					span{
						font-size: 0.26rem;
						color: #666;
						padding-left: 0.1rem;
					}
				}
				.groupPrice{
					display: flex;
					align-items:center;
					margin-top: 0.4rem;
					h2{
						font-size: 0.56rem;
						color: #ec2121;
						label{
							font-size: 0.42rem;
						}
						margin-right:0.2rem;
					}
					.priceO{
						display: flex;
						width: 1.58rem;
						flex-wrap:wrap;
						h3{
							font-size: 0.22rem;
							color: #ec2121;
							.borderFu(#ec2121,0.4rem);
							min-width: 1.28rem;
							height: 0.35rem;
							line-height: 0.37rem;
							text-align: center;
							margin-bottom: 0.1rem;
							font-weight: normal;
						}
						s{
							color: #999;
							font-size: 0.24rem;
						}
					}
				}
			}
		}
	}
	.popRule{
    background: #fff;
    .popHead{
      display: flex;
      align-items:flex-start;
      padding: 0.2rem;
      position: relative;
      .borderBFu(#ede9e9);
      .popHLeft{
        img{
          width: 2rem;
          display: block;
          height: 1.6rem;
        }
      }
      .popHCenter{
        width: 60%;
        text-align: left;
        padding-left: 0.2rem;
        h1{
          font-size: 0.35rem;
          height: 0.8rem;
          line-height: 0.8rem;
          color: #ec2121;
        }
        p{
          margin-top: 0.2rem;
          font-size: 0.25rem;
        }
      }
      .popHRight{
        position: absolute;
        top:-0.3rem;
        right: 0.2rem;
        img{
          width: 0.54rem;
          height: 0.54rem;
        }
      }
    }
    .popMain{
      .rule{
        .borderBFu(#ede9e9);
        padding:0 0 0.2rem 0;
        p{
          font-size: 0.25rem;
          text-align: left;
          padding: 0.1rem 0.2rem;
          color: #666666;
        }
        .ruleDetail{
          display: flex;
          padding: 0 0.2rem;
          flex-wrap:wrap;
          span{
            font-size: 0.22rem;
            padding: 0.1rem 0.15rem;
            margin:0.07rem 0.1rem;
            background: #f5f5f5;
            border-radius:0.15rem;
            color:#272727;
          }
          .activeSpan{
            background: #ec2121;
            color:#fff;
          }
        }
      }
      .number{
        padding: 0.2rem 0;
      }
    }
    .popFooter{
      height: 0.8rem;
      line-height: 0.8rem;
      font-size: 0.3rem;
      color: #fff;
      background: #ec2121;
    }
  }
}
</style>